
//封装函数,小块移动
function move(img){
	var wrapW=wrap.offsetWidth;
	var speed=Math.random();
	var leftV = img.offsetLeft;
	var topV = img.offsetTop;
	var a=leftV;
	var b=topV;
	var speedx=random(0,1)?1:-1;
	var speedy=random(0,1)?1:-1;
	var timer = setInterval(function() {
		
		
		
		if(leftV/wrapW<=(a/wrapW-0.03)||leftV/wrapW>=(a/wrapW+0.03)){
			speedx=speedx*(-1);
			speedy=speedy*(-1);
		}
		leftV -= speed*speedx;
		topV -=speed*speedy;
		img.style.left = leftV + "px";
		img.style.top = topV + "px";
		
	}, 50);
		
		
		
};
//封装一个数,可能是正也可能是负
function random(m,n){
	
	return Math.floor(Math.random()*(n-m+1)+m)
	
}


